package com.hc.smsbackup.app.activity;

import java.util.List;

import com.hc.smsbackup.R;
import com.hc.smsbackup.sms.SMSData;
import com.hc.smsbackup.sms.SMSReader;
import com.hc.smsbackup.xml.XMLWriter;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		TextView txtDsp = (TextView) findViewById(R.id.txtDsp);

		try {

			List<SMSData> smsList = new SMSReader(this).getSMSInbox();
			new XMLWriter().writeSMSToXml(smsList);

			txtDsp.setText(Environment.getExternalStorageDirectory().getAbsolutePath()
					+ "/data.xml");

		} catch (Exception e) {

			Log.d("sms", e.getMessage());
			txtDsp.setText(e.getMessage());
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
